home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions DeltaBarDelta component
-
- #include "NSDLL.h"
-
- /*****************************/
- /* Gradient search procedure */
-
- __declspec(dllexport) void performDeltaBarDelta(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *step, // Pointer to vector of learning rates for each weight
- int length, // Length of learning rate vector
- NSFloat momentum, // Momentum rate for all weights
- NSFloat *delta, // Last weight Update
- NSFloat *gradient, // Gradient vector from backprop component
- NSFloat *smoothedGradient, // Smoothed gradient vector
- NSFloat beta, // Multiplicative constant
- NSFloat kappa, // Additive constant
- NSFloat zeta // Smoothing factor
- )
- {
- int i;
-
- for (i=0; i<length; i++) {
- if (smoothedGradient[i]*gradient[i] > 0)
- step[i] += kappa;
- else
- if (smoothedGradient[i]*gradient[i] < 0)
- step[i] -= beta*step[i];
- smoothedGradient[i] = (1-zeta)*gradient[i] + zeta*smoothedGradient[i];
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- /*
- __declspec(dllexport) DLLData *allocDeltaBarDelta(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int length, // Length of the weight vector
- BOOL individual // Indicates whether their is one learning rate for all weights (FALSE),
- // or each weight has its own learning rate
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- return instance;
- }
-
- __declspec(dllexport) void freeDeltaBarDelta(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
- */
-